<template>
	<view class="orderMainAre">
		<view class="calc display column orderAre borderR" v-if="type==1">
			<view class="display flow titleAre">
				<image src="/static/images/icon/shopIcon.png" style="width: 32rpx;height: 29rpx;"></image>
				<text class="shopName">{{goodsList.supplier.supplier_name}}</text>
				<uni-icons :type="'arrowright'" :color="'grey'" size="16" />
			</view>
			<view class="display flow orderItemAre">
				<image :src="goodsList.skuList.img" class="shopImg" ></image>
				<view class="display column orderItem" style="width: 55%;">
					<text class="fontHide2" style="margin-bottom: 10rpx;">{{goodsList.product_name}}</text>
					<text class="pColor fontHide">{{goodsList.skuList.properties}}</text>
				</view>
				<view class="display column orderItem" style="align-items: flex-end;">
					<text class="price">￥{{goodsList.skuList.price}}</text>
					<text class="pColor">x{{goodsList.goodsNum}}</text>
				</view>
			</view>
			<view class="display column mainAre">
				<view class="display flow mainItem">
					<text>运费</text>
					<text>{{freightNum}}</text>
				</view>
				<view class="display flow mainItem">
					<text>订单备注</text>
					<input class="input" type="text" @input="InputVal($event,goodsList.supplier_id)" placeholder="选填,请先和商家协商一致"/>
				</view>
				<view class="display flow mainItem" style="justify-content: flex-end;">
					<text class="pColor" style="margin-right: 10rpx;">共{{goodsList.goodsNum}}件</text>
					<text>小计： <text class="price">￥{{totalNum}}</text></text>
				</view>
			</view>
		</view>
		<view class="calc display column orderAre borderR" v-for="(item,index) in goodsList" :key="index" v-else>
			<view class="display flow titleAre">
				<image :src="item.shop_content.supplier_img" style="width: 32rpx;height: 32rpx;"></image>
				<text class="shopName">{{item.shop_content.supplier_name}}</text>
				<uni-icons :type="'arrowright'" :color="'grey'" size="16" />
			</view>
			<view class="display flow orderItemAre" v-for="(cell,idx) in item.items" :key="idx">
				<image :src="cell.sku_list.img" class="shopImg" ></image>
				<view class="display column orderItem" style="width: 55%;">
					<text class="fontHide2" style="margin-bottom: 10rpx;">{{cell.product_content.product_name}}</text>
					<text class="pColor fontHide">{{cell.sku_list.properties}}</text>
				</view>
				<view class="display column orderItem" style="align-items: flex-end;">
					<text class="price">￥{{cell.price}}</text>
					<text class="pColor">x{{cell.num}}</text>
				</view>
			</view>
			<view class="display column mainAre">
				<view class="display flow mainItem" v-if="item.shop_content.freight">
					<text>运费</text>
					<text>{{item.shop_content.freight!='0.00'?item.shop_content.freight:'包邮'}}</text>
				</view>
				<view class="display flow mainItem">
					<text>订单备注</text>
					<input class="input" type="text" @input="InputVal($event,item.supplier_id)" placeholder="选填,请先和商家协商一致"/>
				</view>
				<view class="display flow mainItem" style="justify-content: flex-end;">
					<text class="pColor" style="margin-right: 10rpx;">共{{item.totalNum}}件</text>
					<text>小计： <text class="price">￥{{item.subtotal}}</text></text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import util from '@/common/util.js'
	export default {
		name: "orderList",
		props: ['goodsList','type'],
		computed:{
			freightNum(){
				let freight = '包邮'
				if(this.type == 1){
					if(this.goodsList){
						console.log(this.goodsList.supplier)
						if(this.goodsList.supplier.freight && this.goodsList.supplier.freight != '0.00'){
							freight = this.goodsList.supplier.freight
						}
					}
				}
				return freight
			},
			totalNum(){
				var that = this
				if(that.type == 1){
					if(that.goodsList){
						that.total = util.calculate(that.goodsList.skuList.price,that.goodsList.goodsNum,that.goodsList.supplier.freight)
					}
				}
				return Number(that.total).toFixed(2)
			}
		},
		data() {
			return {
				
			};
		},
		methods:{
			InputVal(e,id){
				this.$emit('InputVal',e,id)
			}
		}
	}
</script>

<style lang="scss">
	@import '@/common/css/orderList.scss';
</style>
